package a.d;

import a.c.ab;
import a.c.*;
import a.c.d;
import a.c.e;
import a.c.m;
import a.c.x;
import a.c.y;
import a.c.z;

import java.util.Comparator;

public class q
{
  public static int a;
  
  public static d a(a.c.q paramq, a.c.k paramk, a.c.n paramn)
  {
    boolean bool2 = w.e;
    boolean bool1 = w.d;
    do
    {
      localObject = paramq.w();
      while (!bool1)
      {
        if (!((m)localObject).e()) {
          break;
        }
        paramq.a(((m)localObject).a());
        ((m)localObject).f();
      }
    } while (bool2);
    Object localObject = paramk;
    bb localbb = new bb(paramq.v());
    localbb.a(new Comparator()
    {
      private final a.c.k val$pd;
      
      public int compare(Object paramAnonymousObject1, Object paramAnonymousObject2)
      {
        return ((w)this.val$pd.get(paramAnonymousObject1)).compareTo(this.val$pd.get(paramAnonymousObject2));
      }
    });
    return a(paramq, localbb, paramk, paramn);
  }
  
  public static d a(z paramz, a.c.q paramq, x paramx, a.c.n paramn)
  {
    boolean bool2 = w.e;
    boolean bool1 = w.d;
    paramq.o();
    paramz = new z(paramz.h());
    paramz.k();
    y localy = paramz.h();
    do
    {
      while (!bool1)
      {
        if (!localy.e()) {
          break;
        }
        paramx.a(paramq.i(), localy.j());
        localy.f();
      }
    } while (bool2);
    return a(paramq, new bb(paramq.v()), paramx, paramn);
  }
  
  public static d b(a.c.q paramq, a.c.k paramk, a.c.n paramn)
  {
    int i = 0;
    if ((w.e) || (paramn == null))
    {
      paramq.C();
      i = 1;
    }
    d locald = a(paramq, paramk, paramn);
    if (locald != null) {
      a(paramq, paramk, paramn, locald);
    }
    if (i != 0) {
      paramq.a(paramn);
    }
    return locald;
  }
  
  private static int a(a.c.q paramq, a.c.k paramk, a.c.n paramn, d paramd)
  {
    boolean bool2 = w.e;
    boolean bool1 = w.d;
    if (!bool2) {
      if (paramq.k() <= 3) {
        return 0;
      }
    }
    boolean[] arrayOfBoolean = new boolean[paramq.m()];
    for (d locald1 = paramd; paramd != locald1; locald1 = b(locald1, paramn)) {
      arrayOfBoolean[locald1.d()] = true;
    }
    ab localab = new ab(paramq.w());
    do
    {
      if (bool1) {
        break;
      }
    } while (bool2);
    int i = 0;
    do
    {
      do
      {
        d locald2;
        d locald3;
        d locald4;
        d locald5;
        do
        {
          int j;
          do
          {
            w localw1;
            w localw2;
            w localw3;
            w localw4;
            do
            {
              do
              {
                do
                {
                  if (localab.isEmpty()) {
                    break;
                  }
                  locald2 = localab.o();
                  locald3 = (d)paramn.get(locald2);
                } while (arrayOfBoolean[locald2.d()] != 0);
                if ((bool2) || (bool1)) {
                  break label377;
                }
              } while (arrayOfBoolean[locald3.d()] != 0);
              locald4 = b(locald3, paramn);
              locald5 = b(locald2, paramn);
              localw1 = (w)paramk.get(locald4.e());
              localw2 = (w)paramk.get(locald4.f());
              localw3 = (w)paramk.get(locald5.e());
              localw4 = (w)paramk.get(locald5.f());
            } while (((!bool2) && (!k.b(localw4, localw1, localw2))) || ((!bool2) && (!k.b(localw2, localw3, localw4))));
            j = k.a(localw1, localw2, localw3, localw4);
          } while ((j == 0) && (bool2));
        } while (j <= 0);
        d locald6 = b(locald4, paramn);
        d locald7 = b(locald5, paramn);
        localab.c(locald4);
        localab.c(locald6);
        localab.c(locald5);
        localab.c(locald7);
        paramq.a(locald2, locald6, locald5, 0, 0);
        paramq.a(locald3, locald7, locald4, 0, 0);
        i++;
      } while (bool2);
    } while (!bool1);
    label377:
    return i;
  }
  
  private static d a(a.c.q paramq, bb parambb, a.c.k paramk, a.c.n paramn)
  {
    boolean bool2 = w.e;
    boolean bool1 = w.d;
    a.c.q localq = paramq;
    bb localbb = parambb;
    if (!bool2) {
      if (paramq.n()) {
        return null;
      }
    }
    int i = 0;
    if ((bool2) || (paramn == null))
    {
      paramn = localq.C();
      i = 1;
    }
    Object localObject1 = localbb.o();
    Object localObject2 = (w)paramk.get(localObject1);
    do
    {
      do
      {
        if (localbb.isEmpty()) {
          break;
        }
        if (bool1) {
          break label124;
        }
        if (!((w)localObject2).equals(paramk.get(localbb.a()))) {
          break;
        }
        localbb.b();
      } while (!bool1);
    } while (bool2);
    label124:
    Object localObject4;
    Object localObject5;
    if (!localbb.isEmpty())
    {
      localObject3 = localbb.o();
      localObject2 = (w)paramk.get(localObject3);
      localObject4 = localq.a((e)localObject1, (e)localObject3);
      localObject5 = localq.a((e)localObject3, (e)localObject1);
      paramn.a(localObject4, localObject5);
      paramn.a(localObject5, localObject4);
      localObject1 = localObject3;
    }
    Object localObject3 = localbb.l();
    do
    {
      if (!((a.c.w)localObject3).e()) {
        break;
      }
      localObject4 = ((e)localObject1).j();
      localObject1 = ((a.c.w)localObject3).d();
      localObject5 = (w)paramk.get(localObject1);
      if (bool2) {
        break label403;
      }
      if (bool1) {
        break label402;
      }
      if (((w)localObject5).equals(localObject2))
      {
        a.i.n.a("PRECONDITION VIOLATED! Identical points given to Triangulator!");
        if (bool2) {
          continue;
        }
        if (!bool1) {}
      }
      else
      {
        localObject2 = localObject5;
      }
      do
      {
        while (a((w)localObject5, (d)localObject4, paramk)) {
          localObject4 = a((d)localObject4, paramn);
        }
        do
        {
          d locald1 = b((d)localObject4, paramn);
          d locald2 = localq.a(locald1.e(), locald1, (e)localObject1, null, 0, 0);
          d locald3 = localq.a((e)localObject1, locald1.e());
          paramn.a(locald2, locald3);
          paramn.a(locald3, locald2);
          localObject4 = locald1;
          if (bool1) {
            break;
          }
        } while (a((w)localObject5, (d)localObject4, paramk));
        ((a.c.w)localObject3).f();
      } while (bool2);
    } while (!bool1);
    label402:
    if ((!bool2) && (i == 1)) {
      label403:
      localq.a(paramn);
    }
    if (!bool2) {
      if (localq.m() == 0) {
        return null;
      }
    }
    return localq.s();
  }
  
  private static d a(d paramd, a.c.k paramk)
  {
    d locald = paramd.i();
    if (!w.e) {
      if (locald == null) {
        locald = paramd.e().h();
      }
    }
    return (d)paramk.get(locald);
  }
  
  private static d b(d paramd, a.c.k paramk)
  {
    d locald1 = (d)paramk.get(paramd);
    d locald2 = locald1.k();
    if (!w.e) {}
    return locald2 == null ? locald1.e().j() : locald2;
  }
  
  private static boolean a(w paramw, d paramd, a.c.k paramk)
  {
    if (!w.e) {}
    return k.a(paramw, (w)paramk.get(paramd.e()), (w)paramk.get(paramd.f())) > 0;
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.d.q

 * JD-Core Version:    0.7.0.1

 */